<?php
namespace app\api\controller;

class Auth2 extends Base
{

    public function access_token()
    {
        $return['success'] = true;
        /*
        if ($this->request['username'] != $this->username) {
            $return['success'] = false;
            $return['desc'] = '账户错误';
            $this->ajaxReturn($return);
        }
        $password = strtolower(md5($this->password));
        if ($this->request['password'] != $password) {
            $return['success'] = false;
            $return['desc'] = '密码错误';
            $this->ajaxReturn($return);
        }
        $sign = strtolower(md5($this->request['username'] . $this->password . $this->request['timestamp'] . $this->password));
        if ($sign != $this->request['sign']) {
            $return['success'] = false;
            $return['desc'] = 'sign错误';
            $this->ajaxReturn($return);
        }
        */
        $post['access_token'] = md5($this->ys_config['siteId'] . time());
        $post['expires_stop_time'] = time() + (60 * 60 * 36);
        $data = $this->sendInfo('accessToken', $post);
        if ($data['code'] == 1) {
            $return['success'] = true;
            $return['access_token'] = $post['access_token'];
            $return['expires_at'] = $post['expires_stop_time'];
            $this->ajaxReturn($return);
        }
    }
}